package com.heima.wemedia.controller.v1;


import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.SensitiveDto;
import com.heima.model.wemedia.pojos.WmSensitive;
import com.heima.wemedia.service.WmSensitiveService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/v1/sensitive")
public class WmSensitiveController {

    @Resource
    private WmSensitiveService wmSensitiveService;


    @PostMapping("/list")
    public ResponseResult<List<Map<String,Object>>> list(@Valid @RequestBody SensitiveDto sensitiveDto){
        return wmSensitiveService.myList(sensitiveDto);
    }

    @DeleteMapping("/del/{id}")
    public ResponseResult<String> del (@PathVariable("id")Integer id){
        return wmSensitiveService.del(id);
    }

    @PostMapping("/save")
    public ResponseResult<String> save(@RequestBody WmSensitive wmSensitive){
        return wmSensitiveService.mySave(wmSensitive);
    }

    @PostMapping("/update")
    public ResponseResult<String> update(@RequestBody WmSensitive wmSensitive){
        return wmSensitiveService.myUpdate(wmSensitive);
    }
}
